%module wrapper

%{
#include "api.h"
%}

// 在linux下,swig4.1.0版本可以正常生成,编译通过; 在windows下swig4.0.2版本生成的有问题
%typemap(gotype)(char *symbol[], int nLen) "[]string"

%typemap(in)(char *symbol[], int nLen)
%{
   {
      int i;
	  _gostring_* a;

	  $2 = $input.len;
	  a = (_gostring_*) $input.array;
	  $1 = (char **) malloc (($2 + 1) * sizeof (char *));
	  for (i = 0; i < $2; i++) {
		_gostring_ *ps = &a[i];
		$1[i] = (char *) ps->p;
	  }
	  $1[i] = NULL;
   }
%}


%typemap(gotype)(int nLen, char *goods[]) "[]string"

%typemap(in)(int nLen, char *goods[])
%{
   {
      int i;
	  _gostring_* a;

	  $1 = $input.len;
	  a = (_gostring_*) $input.array;
	  $2 = (char **) malloc (($1 + 1) * sizeof (char *));
	  for (i = 0; i < $1; i++) {
		_gostring_ *ps = &a[i];
		$2[i] = (char *) ps->p;
	  }
	  $2[i] = NULL;
   }
%}

%include "api.h"